<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta name = "format-detection" content = "telephone=no">
    <title><?php echo getStoreName($_GET['local_id']);?>-领取礼券</title>
    <link rel="stylesheet" href="/Public/Home/css/coupon.css?v=20170322002">
    <!--不识别数字为手机-->
<meta name="format-detection" content="telephone=no, email=no"/>
<!--通用js-->
<?php if(isset($signPackage) && !empty($signPackage)){ ?>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js?v=201704270010"></script>
<?php } ?>
<script type="text/javascript" src="/Public/Home/js/require.js"></script>
<script type="text/javascript" src="/Public/Home/js/baseLoading.js?v=201705240001"></script>
<script src="/Public/Home/js/jquery.min.js" ></script>
<script src="/Public/Home/js/pincode-input.js" ></script>
<script src="/Public/Home/js/parabola.js" ></script>
<script src="/Public/Home/js/lazyload/jquery.lazyload.min.js"></script>
<script type="text/javascript">
    _global.isLogin = !!"<?php echo $wx_member_id; ?>";
	var isWxShareDiy = typeof yc_share_diy === "undefined" ? false : yc_share_diy;
	var yc_wx_shareImgPath = "";
	<?php if(isset($weixin_logo) && !empty($weixin_logo)){ ?>
		yc_wx_shareImgPath = "/Uploads/<?php echo ($weixin_logo["image"]); ?>";
	<?php } ?>
    var yc_pass_arr = {'local_id':"<?php echo I('local_id',1);?>",'top_local_id':"<?php echo I('top_local_id',1);?>"};
	if(parseInt(yc_pass_arr["local_id"]) == 21){
		_global.isStopSell = true;
	}
    <?php if(isset($signPackage) && !empty($signPackage)){ ?>
        _global.isWeiXinLoad = true;
        var isEnableLocation = typeof yc_wx_location === "undefined" ? false : yc_wx_location;
        var yc_wx_options = {
            "enableLocation" : isEnableLocation,
            "refuseCallback" : function(){},
            "mapCallback" : function(){},
            "config" : {
                debug: false,
                appId: '<?php echo $signPackage["appId"];?>',
                timestamp: '<?php echo $signPackage["timestamp"];?>',
                nonceStr: '<?php echo $signPackage["nonceStr"];?>',
                signature: '<?php echo $signPackage["signature"];?>',
                jsApiList: [
                    'checkJsApi'
                ]
            }
        };
        var isInHeader = typeof yc_wx_useInHeader === "undefined" ? true : yc_wx_useInHeader;
        if(isInHeader){
            wxAutoConfig(yc_wx_options);
        }
    <?php } ?>
</script>
</head>
<body>
<div id="ajax-couponlist" class="coupon-get-list"></div>


<div class="coupon-info-popup">
    <a href="javascript:;" class="close"></a>
    <div class="cp-body">
        <span id="curCouponTit" class="tit"></span>
        <div id="curCouponDesc" class="desc">
            正在加载中...
        </div>
    </div>
</div>
<link rel="stylesheet" href="/Public/Home/css/phoneCheck.css">
<div class="alert-popup bindPhone">
    <p>你还没有绑定手机号，为了你更好的体验怡臣请先绑定手机号。</p>
    <p><a href="javascript:void(0);" class="cancel">先看看</a><a href="javascript:void(0);" class="confirm">绑定手机</a></p>
</div>
<div class="bindPhone-box" style="display:none">
    <span class="close"></span>
    <div class="inputInfo">
        <h1>验证手机号</h1>
        <ul>
            <li><input type="text" placeholder="请输入绑定手机号" id="phone"> <a href="javascript:void(0);" id="yzCaptcha">获取验证码</a></li>
            <li>
                <div class="pincode-input-container touch" id="pincode-list">
                    <div style="display: none;">
                        <input type="password" readonly pattern="[0-9]*" inputmode="numeric" id="preventautofill" autocomplete="off">
                    </div>
                    <div class="touchwrapper touch4">
                        <input type="password" pattern="[0-9]*" readonly inputmode="numeric" maxlength="4" autocomplete="off" class="form-control pincode-input-text">
                        <table class="touchtable">
                            <tbody>
                            <tr>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td class="last"></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="text-danger pincode-input-error"></div>
                </div>
                <input type="text" id="code-input" style="display:none;">
                <p class="code-tips" style="display:none;"></p>
            </li>
        </ul>
    </div>
    <div class="success" style="display:none;">
        <ul>
            <li>
                <span>绑定成功!</span>
                <p>该窗口<i>3</i>秒后自动关闭</p>
            </li>
        </ul>
    </div>
</div>

<script type="text/javascript">
    var isDetailInit = false;
    var isAjaxTake = false;
    var isAjaxDetail = false;
    function showCouponDetail(obj, e){

        if(isAjaxDetail) return;
        isAjaxDetail = true;
        var _self = $(obj);
        var cparent = _self.parents(".oneitem");
        $("#curCouponTit").html(cparent.find(".tit").html());
        $("#curCouponDesc").html("正在加载中...");
        _global.promote.popup(".coupon-info-popup", isDetailInit);
        if(!isDetailInit){
            isDetailInit = true;
        }
        var _id = cparent.attr("data-id");

        $.ajax({
            url: '/Home/NewUserCoupon/isCouponBagDetail'+getFixedExtraUrl(),
            type: 'post',
            data: { 'id': _id},
            dataType: 'json',
            success: function(rs) {
                if(rs && rs.data != null){
                    var output = "";
                    var dlen = rs.data.length;
                    for(var i = 0; i < dlen; i++){
                        output += rs.data[i] + (i == dlen - 1 ? "。" : ";<br/>");
                    }
                    $("#curCouponDesc").html(output);
                }
                isAjaxDetail = false;
            },
            error: function() {
                $("#curCouponDesc").html("加载失败!");
                isAjaxDetail = false;
            }
        });
    }
    function takeCoupon(obj, e){
        var _self = $(obj);
        if(_self.hasClass("disable")) return;
        e.preventDefault();
        _global.checkPhoner.verifyfunc = function(rs){
            if(rs){
                ajaxTakeCoupon(e, _self);
                return true;
            }else{
                return false;
            }
        };
        _global.checkPhoner.succfunc =function(){
            ajaxTakeCoupon(e, _self);
        };
        _global.checkPhoner.run(e);
    }
    function ajaxTakeCoupon(e, _self){
        if(isAjaxTake){
            return false;
        }
        isAjaxTake = true;
        var cparent = _self.parents(".oneitem");
        var _id = cparent.attr("data-id");
        $.ajax({
            url: '/Home/NewUserCoupon/getCouponBag'+getFixedExtraUrl(),
            type: 'post',
            data: { 'id': _id},
            dataType: 'json',
            success: function(rs) {
                _global.promote.alertPopup(rs.msg);
                // status 1 2 3
                if(rs.status == 3){
                    _self.removeClass('active').addClass('disable').text("已领");
                }else if(rs.status == 0){
                    _self.removeClass('active').addClass('disable').text("已抢光");
                }else if(rs.status == 1){
                    _self.removeClass('active').addClass('disable').text("过期");
                }else if(rs.status == 2){
                    _self.removeClass('active').addClass('disable').text("异常");
                }else if(rs.status == 4){
                    _self.removeClass('active').addClass('disable').text("数据异常");
                }
                isAjaxTake = false;
            },
            error: function() {
                _global.promote.alertPopup('服务器异常，请稍后重试！');
                isAjaxTake = false;
            }
        });
    }
    require(['member/couponGet']);
</script>




</body>
</html>